home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / CUCD / Programming / EasyPLUGINs / examples / register_demo1.e < prev    next >
Encoding:
Text File  |  1997-11-21  |  2.8 KB  |  88 lines

  1. /*
  2. **
  3. ** Demo for register PLUGIN
  4. **
  5. ** Copyright: Ralph Wermke of Digital Innovations
  6. ** EMail    : wermke@gryps1.rz.uni-greifswald.de
  7. ** WWW      : http://www.user.fh-stralsund.de/~rwermke/di.html
  8. **
  9. ** Date     : 02-Nov-1997
  10. **
  11. */
  12.  
  13. OPT PREPROCESS
  14.  
  15. MODULE 'tools/easygui','tools/exceptions','tools/installhook',
  16.        'utility/tagitem', 'utility/hooks',
  17.        'easyplugins/register'
  18.  
  19. DEF h:hook, gh, g1, currentslider
  20.  
  21. PROC main() HANDLE
  22. DEF mp:PTR TO register_plugin, labels, listlen
  23.  
  24.    labels :=['One','Two','Three','Four','Five']
  25.    listlen:=ListLen(labels)-1
  26.  
  27.    /* init action hook */
  28.    installhook(h, {actionhook})
  29.  
  30.    /* create new instance */
  31.    NEW mp.register([PLA_Register_Titles, labels,
  32.                     PLA_Register_ActionHook, h,
  33.                     PLA_Register_ActivePage, PLV_Register_ActivePage_Next,
  34.                     TAG_DONE])
  35.  
  36.    /* set attributes before gui is open */
  37.    mp.set(PLA_Register_ActivePage, PLV_Register_ActivePage_Next)
  38.    mp.set(PLA_Register_Disabled, TRUE)
  39.  
  40.    /* open gui */
  41.    easyguiA('Register Test',
  42.             [ROWS,
  43.                [PLUGIN, {ignore}, mp],
  44.                [BEVEL,
  45.                   [EQCOLS,
  46.                      [SBUTTON, {setfirst}, 'First', mp],
  47.                      [SBUTTON, {setlast}, 'Last', mp],
  48.                      [SBUTTON, {setprev}, 'Previous', mp],
  49.                      [SBUTTON, {setnext}, 'Next', mp],
  50.                      [SBUTTON, {dis}, 'Toggle', mp],
  51.                      g1:=[SLIDE, {scroll}, NIL, FALSE, 0, listlen, 0, 2, '', mp]
  52.                   ]
  53.                ],
  54.                [SBUTTON, {cwin}, 'Close', mp]
  55.             ],
  56.             [EG_GHVAR,{gh}, TAG_DONE])
  57. EXCEPT
  58.    END mp
  59.    report_exception()
  60. ENDPROC
  61.  
  62. /* action functions */
  63. PROC ignore(i, mp:PTR TO register_plugin) IS EMPTY
  64. PROC setfirst(mp:PTR TO register_plugin, i) IS mp.set(PLA_Register_ActivePage, PLV_Register_ActivePage_First)
  65. PROC setlast(mp:PTR TO register_plugin, i) IS mp.set(PLA_Register_ActivePage, PLV_Register_ActivePage_Last)
  66. PROC setnext(mp:PTR TO register_plugin, i) IS mp.set(PLA_Register_ActivePage, PLV_Register_ActivePage_Next)
  67. PROC setprev(mp:PTR TO register_plugin, i) IS mp.set(PLA_Register_ActivePage, PLV_Register_ActivePage_Prev)
  68. PROC dis(mp:PTR TO register_plugin, i) IS mp.set(PLA_Register_Disabled, Not(mp.get(PLA_Register_Disabled)))
  69. PROC scroll(mp:PTR TO register_plugin, info, x) IS mp.set(PLA_Register_ActivePage, currentslider:=x)
  70.  
  71. /* set attributes during window is closed */
  72. PROC cwin(mp:PTR TO register_plugin, i)
  73.    closewin(gh)
  74.    mp.set(PLA_Register_ActivePage, PLV_Register_ActivePage_Last)
  75.    mp.set(PLA_Register_Disabled, TRUE)
  76.    openwin(gh)
  77. ENDPROC
  78.  
  79. /* sample action hook */
  80. PROC actionhook(hook, obj, x)
  81.    PrintF('hook=$\h obj=$\h current=\d\n', hook, obj, x)
  82.    IF x<>currentslider        /* avoid recursion */
  83.       setslide(gh, g1, x)
  84.       currentslider:=x
  85.    ENDIF
  86. ENDPROC
  87.  
  88.